﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Learn.Wcf.Service;
using System.ServiceModel;

namespace Learn.WCF.Hosting
{
    class Program
    {
        static void Main(string[] args)
        {
            using (ServiceHost calculatorServiceHost = new ServiceHost(typeof(Service1)))
            {
                // 设置委托匿名函数，当服务打开时能看到提示  
                calculatorServiceHost.Opened += delegate
                {
                    Console.WriteLine("Calculator Service begin to listen via the Address:{0}", calculatorServiceHost.BaseAddresses[0].ToString());
                };
                // 打开服务，所有的配置都从App.config中读取，不需要重新写什么  
                calculatorServiceHost.Open();
                // 阻塞程序，否则一启动就结束了  
                Console.Read();
            }
        }
    }
}
